<template>
	<view :style="viewColor" >
		
			<view class="page_con">
				<view class="dialog_nav" v-show="currentPage" :style="{ top: navH + 'rpx' }">
					<view class="dialog_nav_item" :class="item.after" v-for="(item,index) in selectNavList" :key="index"
						@click="linkPage(item.url)">
						<text class="iconfont" :class="item.icon"></text>
						<text class="pl-20">{{item.name}}</text>
					</view>
				</view>	
				<view class="grass_header" >
					<view  class="header">
						<view class="sys-head tui-skeleton" :style="{ height: navTop+'px;'  }"></view>
						<!-- #ifdef MP -->
						<view class="navTab" :style="'margin-right:'+menuButtonInfo.width+'px'" >
							<!-- <view v-if="community_status == 1" @click="goRelease" class="release_btn acea-row row-center-wrapper">
								<text class="iconfont icon-fabu"></text></view> -->
							<view class="acea-row row-between-wrapper" :style="'line-height:'+navHeights+'px;' ">
								<view class="head-wrapper" id="home" :style="{ top: (navTop+2)+'px;'  }">
									<view class="head-menu">
										<view class='iconfont icon-fanhui2' @click="returns"></view>
										<view  class="iconfont" @click="showNav " style="display: flex;justify-content: center;align-items: center;">
											<image style="width: 45rpx;height: 60rpx;" mode="widthFix" :src="spfabu" ></image>
										</view>
									</view>
								</view>
								<view :class="tabActive == 0 ? 'on' : ''" class="nav-item" @click="ChangeActive(0,200)">关注</view>
								<view :class="tabActive == 1 ? 'on' : ''" class="nav-item" @click="tabActive=1;top=300;">发现</view>
								<navigator url="/pages/plantGrass/plant_search/index" hover-class="none" >
								<view :class="tabActive == 2 ? 'on' : ''" class="nav-item" @click="tabActive=1;top=300;">搜索</view>
								</navigator>
							</view>
							<!-- <navigator v-if="isLogin && community_status == 1" :url="'/pages/plantGrass/plant_user/index?id='+userInfo.uid">
								<image class="avatar" :src="userInfo.avatar ? userInfo.avatar : 'https://gpt.ganputangyouxuan.com/static/images/f.png'"></image>
							</navigator> -->
							<view :style="'height:'+marTop+'px;'"></view>
						</view>
						<!-- #endif -->
						<!-- #ifdef H5 -->
						<view class="navTab" style="padding-top: 46rpx;padding-right:120rpx" >
							<!-- <view v-if="community_status == 1" @click="goRelease" class="release_btn acea-row row-center-wrapper">
								<text class="iconfont icon-fabu"></text></view> -->
							<view class="acea-row row-between-wrapper" :style="'line-height:'+navHeights+'px;' ">
								<view class="head-wrapper" id="home" style="top:16rpx;left: 20rpx;">
									<view class="head-menu">
										<view class='iconfont icon-fanhui2' @click="returns"></view>
										
										<view  class="iconfont" @click="showNav">
											<image style="width: 45rpx;height: 60rpx;" mode="widthFix" :src="spfabu" ></image>
										</view>
									</view>
								</view>
								<view :class="tabActive == 0 ? 'on' : ''" class="nav-item" @click="ChangeActive(0,200)">关注</view>
								<view :class="tabActive == 1 ? 'on' : ''" class="nav-item" @click="tabActive=1;top=300;">发现</view>
								<navigator url="/pages/plantGrass/plant_search/index" hover-class="none" >
								<view :class="tabActive == 2 ? 'on' : ''" class="nav-item" @click="tabActive=1;top=300;">搜索</view>
								</navigator>
							</view>
							<!-- <navigator v-if="isLogin && community_status == 1" :url="'/pages/plantGrass/plant_user/index?id='+userInfo.uid">
								<image class="avatar" :src="userInfo.avatar ? userInfo.avatar : 'https://gpt.ganputangyouxuan.com/static/images/f.png'"></image>
							</navigator> -->
							<view :style="'height:'+marTop+'px;'"></view>
						</view>
						<navigator class="btn skeleton-rect" url="/pages/chat/customer_list/index?type=0" hover-class="none">
							<view class="iconfont icon-xiaoxi" ></view>
							<text class="iconnum" v-if=" userInfo.total_unread " >{{ userInfo.total_unread }}</text>
						</navigator>
						<!-- #endif -->
						
						<!-- <view :style="'height:'+statusBarHeight"></view> -->
						<!-- <view class="search_count">
							<navigator url="/pages/plantGrass/plant_search/index" hover-class="none" class="search"><text class="iconfont icon-xiazai5"></text>搜索想看的文章</navigator>
							<navigator class="search_topic" url="/pages/plantGrass/plant_topic/index">
								<image class="topic_icon" src="/static/images/topic_cate.png"></image>
							</navigator>
						</view> -->
					</view>
					<view class="line"></view>
					<view class="longTab" v-if="tabActive == 1">
						<scroll-view scroll-x="true" style="white-space: nowrap; display: flex;height:50rpx" scroll-with-animation class="menu" :scroll-left="tabLeft" show-scrollbar="true">
							<view class="longItem"
							:data-index="index"
							:class="index === tabClick ? 'click' : ''"
							v-for="(item, index) in menuList"
							:key="index"
							:id="'id' + index"
							@click.stop="selectMenu(item, index, true)">{{ item.cate_name }}</view>
						</scroll-view>
					</view>
				</view>
				
				<scroll-view class="main" :class="{'scroll-main' : tabActive == 0}"  scroll-y="true" @scroll="followScroll">
					<view class="tab-cont" id="main" @touchmove="onTouchmove">
						<!-- 关注 -->
						<view style="display: none;">
							<view v-if="isLogin && followList.length > 0" class="follow_count" :class="(newData.status && newData.status.status && showTab) ? 'showFoot' : ''">
								<block v-for="(item, index) in followList" :key="index">
									<view class="list_count">
										<view class="title">
											<navigator hover-class="none" :url="'/pages/plantGrass/plant_user/index?id='+item.uid" v-if="item.author" class="author">
												<easy-loadimage class="picture" mode="widthFix" :image-src="item.author&&item.author.avatar || 'https://gpt.ganputangyouxuan.com/static/images/f.png'"></easy-loadimage>
												<text class="name">{{item.author.nickname || ''}}</text>
											</navigator>
											<view class="time">{{item.time}}</view>
										</view>
										<view class="product">
											<productConSwiper v-if="item.is_type == 1" :imgUrls="item.image"></productConSwiper>
											<view v-else class="videoSwiper" @click="goVideo(item)">
												<image class="image" :src="item.image[0]"></image>
												<view  v-if="item.is_type == 2" class="plant-show">
													<text  class="  iconfont icon-shipin1"></text>
												</view>
												<!-- <image v-if="item.is_type == 2" class="video_img" src="../../static/images/stop.png"></image> -->
											</view>
										</view>
										<view class="pro_describle">
											<view class="mentioned" v-if="item.relevance && item.relevance.length > 0" @click="openMore(item)">
												<text class="title">查看朋友的品质推荐({{item.relevance.length}})</text>
												<view class="product_more">
													<view class="item">
														<easy-loadimage v-if="indexn<4" v-for="(itemn, indexn) in item.relevance" :key="indexn" mode="widthFix" :image-src="(itemn.spu && itemn.spu.image) || itemn.image" class="more_image"></easy-loadimage>
													</view>
													<text class="iconfont icon-gengduo3"></text>
												</view>
											</view>
											<view v-if="!item.show && item.content.length > 110" class="product_info">
												<text class="text">
													{{item.content.substring(0,90)+'...'}}
												</text>
												<text @click.stop="showMore(item)" class="unfold_btn">展开</text>
											</view>
											<view v-else class="product_info">
												<text class="text">
													{{item.content}}
												</text>
											</view>
											<navigator v-if="item.topic" hover-class="none" class="product_cate" :url="'/pages/plantGrass/plant_search_list/index?id='+item.topic.topic_id">
												<view>
													<text class="icon">#</text><text class="text">{{item.topic.topic_name}}</text>
												</view>
											</navigator>
											<view class="foot_bar">
												<!-- #ifdef MP -->
												<button class="time iconfont icon-fenxiang2" open-type="share" hover-class='none' @click="shareFriend(item)"></button>
												<!-- #endif -->
												<!-- #ifndef MP -->
												<button></button>
												<!-- #endif -->
												<view class="item">
													<view class="item_count" @click.stop="likeToggle(item)">
														<text class="iconfont" :class="item.relevance_id ? 'icon-shoucang1' : 'icon-dianzan'"></text>
														<text>{{item.count_start > 0 ? item.count_start : '点赞'}}</text>
													</view>
													<view v-if="community_reply_status == 1" class="item_count" @click="openCommon(item,index)">
														<text class="iconfont icon-pinglun"></text>
														<text>{{item.count_reply > 0 ? item.count_reply : '评论'}}</text>
													</view>
												</view>
											</view>
										</view>
									</view>
								</block>
							</view>
							
						</view>
						<view class=""  v-if="tabActive==0">
							
									<scroll-view v-if="isLogin && followList.length > 0" @scroll="scrollLeft" scroll-y="true" :style="'height:'+(swiperHeight-50)+'px'" id="goodss"
										refresher-enabled="true" :refresher-threshold="100"
										:refresher-triggered="triggeredDiscovers"
										@refresherrefresh="onRefreshDiscovers" @refresherpulling="onPullings"
										@refresherrestore="onRestores" @refresherabort="onAbort">
											
											<view class="goods" v-if="isLogin && followList.length > 0" style="padding: 30rpx 0 100rpx 0;justify-content: center;">
												<WaterfallsFlow   :isShow="false" :focus="true" :wfList='followList' :isFind="true" @likeToggle="likeToggle"/>
											</view>
										
										
										
									</scroll-view>
									<!-- 演唱会音乐会 -->
							<view v-if="followList.length == 0 && !focusLoading && isLogin" class="empty   row-middle acea-row row-column">
								<image :src="`${domain}/static/images/nodata.png`"></image>
								<text class="nocontent">── 暂无内容 ── </text>
							</view>
							<!-- <nologin-page v-if="!isLogin"></nologin-page> -->
						</view>
						<!-- 发现 -->
						<view v-show="tabActive === 1">
							<!-- 演唱会音乐会 -->
							<swiper :interval="interval" indicator-color="rgba(255,255,255,0.6)" :current="swiperCurrent" @change="swiperChange" :style="'height:'+swiperHeight+'px;'" >
								<block v-for="(item,index) in menuList" :key="index">
									<swiper-item :item-id="`${item.category_id}`">
										<scroll-view @scroll="scrollLeft" scroll-y="true" :style="'height:'+swiperHeight+'px'" id="goods"
											refresher-enabled="true" :refresher-threshold="100"
											:refresher-triggered="triggeredDiscover"
											@refresherrefresh="onRefreshDiscover" @refresherpulling="onPulling"
											@refresherrestore="onRestore" @refresherabort="onAbort">
											<view v-if="cateGoods[item.category_id] && cateGoods[item.category_id].goods.length" class="goods-wrap" id="goods">
												<view class="goods"  style="padding-bottom: 280rpx;">
													<WaterfallsFlow  :isShow="false" :wfList='cateGoods[item.category_id].goods' :isFind="true" @likeToggle="likeToggle"/>
												</view>
											</view>
											<view :hidden="cateGoods[item.category_id] && !cateGoods[item.category_id].goodsLoading" class="acea-row row-center-wrapper loadingicon">
												<text class="iconfont icon-jiazai loading"></text>{{!cateGoods[item.category_id] ? 0 : cateGoods[item.category_id].goodsLoading}}
											</view>
											<view v-if="cateGoods[item.category_id] && cateGoods[item.category_id].goods.length == 0 && !cateGoods[item.category_id].goodsLoading" class="empty  row-middle acea-row row-column">
												<image :src="`${domain}/static/images/nodata.png`"></image>
												
												<text class="nocontent"> ───  {{item.category_id == -1 ? '好像还没有内容' : '好像还没有内容'}}  ───</text>
											</view>
											
										</scroll-view>
									</swiper-item>
								</block>
							</swiper>
						</view>
					</view>
				
				</scroll-view>
				
			</view>
			<!-- 他提到的宝贝弹窗 -->
			<mentioned ref="mentioned" :isHome="true" @close="closePopup" :list="moreList" :uid="authorUid"></mentioned>
			<!-- 评论弹窗 -->
			<comment ref="comment" :isShow="showComment" :userInfo="userInfo" :bottom="bottom" @successFul="commentSucces" @close="close"></comment>
			
			<!--自定义底部tab栏-->
			<customTab :newData="newData" :activeRouter="activeRouter"></customTab>
		
		
	</view>
</template>
<script>
	// +----------------------------------------------------------------------
	// | jufeiniu [中皮健康-陈皮之美-百年传承]
	// +----------------------------------------------------------------------
	// | Copyright (c) 2023 https://jufeiniu.com/ All rights reserved.
	// +----------------------------------------------------------------------
	// | Author: 巨说还行-乔欣弥弥-巨肥牛 <jufeiniu@163.com>
	// +----------------------------------------------------------------------
	// | Personal site: https://jufeiniu.com/
	// +----------------------------------------------------------------------
	let statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
	import WaterfallsFlow from '@/components/plantWaterfallsFlow/WaterfallsFlow.vue'
	import mentioned from '@/components/mentioned.vue';
	import comment from '@/components/comment.vue';
	import { getNavigation } from '@/api/public.js';
	import customTab from '@/components/customTab';
	import { graphicLstApi, getTopicList, graphicStartApi, focusArticleLst } from '@/api/community.js';
	import { getUserInfo } from '@/api/user.js';
	import { mapGetters } from "vuex";
	import productConSwiper from '@/components/plantConSwiper';
	import easyLoadimage from '@/components/easy-loadimage/easy-loadimage.vue';
	import { HTTP_REQUEST_URL } from '@/config/app';
	import { toLogin } from '@/libs/login.js';
	import { configMap } from '@/utils';
	// import nologinPage from '@/components/nologinPage'
	// import {getIcons} from '@/api/newVersion.js'
	const app = getApp();
	export default {
		components: {
			WaterfallsFlow,
			productConSwiper,
			mentioned,
			comment,
			easyLoadimage,
			customTab,
			// nologinPage
		},
		data() {
			return {
				domain: HTTP_REQUEST_URL,
				statusBarHeight: statusBarHeight,
				// #ifdef MP
				menuButtonInfo: uni.getMenuButtonBoundingClientRect(),
				// #endif
				tabClick: 0,
				tabLeft: 0,
				isLeft: 0, //导航栏下划线位置
				isWidth: 0, //每个导航栏占位
				windowHeight: 0,
				swiperHeight: 0,
				childIndex: 0,
				showComment: false,
				triggered: false,
				triggeredDiscover: false,
				userInfo: {},
				goods: [], // 商铺演唱会音乐会
				followList: [], //关注列表
				menuList: [],
				moreList: [],
				commList: [], //评论列表
				goodsList: [],
				navShow: false,
				navActive: 0,
				tabActive: 1, // 底部切换
				keyword: '',
				sortPrice: true, // 价格排序
				focusLoading: false,
				goodsLoading: false,
				goodsLoaded: false,
				focusLoaded: false,
				loadTitle: '加载更多',
				where: {
					category_id: 0,
					page: 1,
					limit: 30
				},
				focusWhere: {
					page: 1,
					limit: 30
				},
				storeScroll: true,
				_freshing: false,
				storeTop: 0,
				storeHeight: 0,
				navHeight: 0,
				avatar: '',
				hederBg: '../static/images/plant_header.png',
				top: 300,
				shareInfo: {},
				actionSheetHidden: true,
				authorUid: 0,
				swiperCur: 0,
				circular: true,
				isScroll: false,
				interval: 3000,
				currentItemId: 0,
				swiperCurrent: 0,
				scrollTop: 0,
				cateGoods:{},
				newData: {},
				activeRouter: '',
				showTab: false,
				//#ifdef MP||APP-PLUS
				bottom: 0,
				//#endif
				//#ifndef MP||APP-PLUS
				bottom: 90,
				//#endif
				windowHeight:0,
				marTop:0,
				homeTop: 59,
				currentPage:false,
				selectNavList: [{
						name: '首页',
						icon: 'icon-shouye8',
						url: '/pages/index/index',
						after: 'dialog_after'
					},
					{
						name: '搜索',
						icon: 'icon-sousuo6',
						url: '/pages/columnGoods/goods_search_con/index',
						after: 'dialog_after'
					},
					{
						name: '购物车',
						icon: 'icon-gouwuche7',
						url: '/pages/order_addcart/order_addcart',
						after: 'dialog_after'
					},
					{
						name: '我的收藏',
						icon: 'icon-shoucang3',
						url: '/pages/users/user_goods_collection/index',
						after: 'dialog_after'
					},
					{
						name: '个人中心',
						icon: 'icon-gerenzhongxin1',
						url: '/pages/user/index'
					},
				],
				navH:"",
				navTop:0,
				navHeights:0,
				sortIndex:0,
				spfabu:"",
				triggeredDiscovers:false,
				videoShow: uni.getStorageSync('videoShow')
			}
		},
		// 滚动监听
		onPageScroll({scrollTop}) {
			
			uni.$emit('scroll');
		},
		onReady() {
			this.isNodes++;
			this.$nextTick(function() {
				// #ifdef MP
				const menuButton = uni.getMenuButtonBoundingClientRect();
				console.log(menuButton)
				this.navTop = menuButton.top
				this.navHeights= menuButton.height
				const query = uni.createSelectorQuery().in(this);
				query
					.select('#home')
					.boundingClientRect(data => {
						this.homeTop = menuButton.top * 2 + menuButton.height - data.height;
					})
					.exec();
				// #endif
			});
		},
		created() {
			var that = this
			// 获取设备宽度
			uni.getSystemInfo({
				success(e) {					
					that.mainWidth = e.windowWidth
					that.isWidth = (e.windowWidth-65) / 8 
					that.isWidth = e.windowWidth / 6;
								that.windowHeight = e.windowHeight;
								that.swiperHeight = that.windowHeight - 205
								that.$set(that, 'swiperHeight', that.windowHeight-150);
				}
			})	
			setTimeout((e) => {
				const query = uni.createSelectorQuery().in(this);
				if(that.tabTitle.length>0){
					query.select('.navTabBox').boundingClientRect(data => {
						that.navHeight = data.height > 42 ? data.height : 42
					}).exec();
				}else{
					that.navHeight = 0
				}
				// #ifdef H5
				query.select('.header').boundingClientRect(data => {
					that.isTop = data.height
					that.marTop = data.height
				}).exec();
				// #endif
				// #ifdef MP || APP-PLUS
				// #ifdef APP-PLUS
				const menuButton = 0
				//#endif
				// #ifdef MP
				const menuButton = uni.getMenuButtonBoundingClientRect();
				//#endif
				query
					.select('.serch-box')
					.boundingClientRect(data => {
						this.marTop = data.height
					}).exec();
				//#endif
			}, 500)
			that.isTop = (uni.getSystemInfoSync().statusBarHeight + this.marTop)
			// that.imgUrls = that.dataConfig.swiperConfig.list
			that.$nextTick(function() {
				setTimeout((e) => {
					// #ifdef H5
					that.swiperTop = that.navHeight+that.marTop
					//#endif
					// #ifdef MP || APP-PLUS
					that.swiperTop = that.navHeight + uni.getSystemInfoSync().statusBarHeight + that.marTop
					//#endif
				}, 500)
			})
		},
		// created() {
		// 	var that = this;
		// 	// 获取设备宽度
		// 	uni.getSystemInfo({
		// 		success(e) {
		// 			that.isWidth = e.windowWidth / 6;
		// 			that.windowHeight = e.windowHeight;
		// 			// that.swiperHeight = that.windowHeight - 205
		// 			that.$set(that, 'swiperHeight', that.windowHeight-150);
		// 		}
		// 	});
		// },
		computed: {
			...mapGetters(['isLogin', 'uid', 'viewColor']),
			...configMap({community_reply_status: 0,community_app_switch: [],community_status: 0,navigation: {}})
		},
		watch: {},
		onLoad: function(options) {
			let that = this;
			that.navH = app.globalData.navHeight+10;
			// getIcons({pinyin:'sp-fabu'}).then(res=>{
				
			// 	this.spfabu=res.data.data[0].image_link
			// })
			// #ifdef H5
			that.homeTop = 10;
			// #endif
			uni.$on('startLike',function(data){
				for(var i = 0; i < that.cateGoods[that.currentItemId]['goods'].length; i++){
					let item = that.cateGoods[that.currentItemId]['goods'][i]
					if(data.community_id == item['community_id']){
						item['count_start'] = data.relevance_id ? item['count_start']+1 : item['count_start']-1
						item['relevance_id'] =  data.relevance_id ? true : false
					}
				}
			})
			if(that.login) this.getFocusArtical();
		},
		onShow() {
			
			this.getCateList();
			this.getGoods();
			let that = this
			let routes = getCurrentPages();
			let curRoute = routes[routes.length - 1].route
			this.activeRouter = '/' + curRoute
			this.getNav();
			if (that.isLogin) {
				that.focusLoading = false;
				that.focusLoaded = false;
				that.focusWhere.page = 1;
				that.followList = [];
				this.getFocusArtical();
				this.getUserInfo();
				
			} else {
				this.userInfo = {}
			}
			uni.setStorageSync('sortIndex','')
		},
		mounted: function() {
			const query = uni.createSelectorQuery().in(this);
			query.select('#main').boundingClientRect(data => {
				this.storeHeight = data.height;
				this.storeTop = data.top;
			}).exec();
		},
		/**
		 * 用户点击右上角分享
		 */
		// #ifdef MP
		onShareAppMessage: function() {
			let that = this;
			that.$set(that, 'actionSheetHidden', !that.actionSheetHidden);
			return {
				title: that.shareInfo.title || '',
				imageUrl: that.shareInfo.image[0] || '',
				path: '/pages/plantGrass/plant_detail/index?id=' + that.shareInfo.community_id + '&spid=' + that.uid,
			}
		},
		onShareTimeline: function() {
			let that = this;
			that.$set(that, 'actionSheetHidden', !that.actionSheetHidden);
			return {
				title: that.shareInfo.title || '',
				query: {
					id: that.shareInfo.community_id,
					spid: that.uid
				},
				imageUrl: that.shareInfo.image[0] || ''
			}
		},
		// #endif
		// onPullDownRefresh() {
		// 		console.log(333)
		// 	if(this.tabActive==0){
		// 		this.page=1
		// 		this.focusArticleLst=[]
		// 			this.getFocusArtical()
		// 	}
		// },
		methods: {
			returns: function() {
				uni.navigateBack()
			},
			ChangeActive(act,top){
				this.top=top;
				this.tabActive = act
				this.focusLoaded=false  
				this.focusLoading=false 
				this.focusWhere.page=1
				this.focusArticleLst=[]
				this.followList=[]
				this.getFocusArtical()
			},
				showNav(){
					if(this.isLogin){
						uni.navigateTo({
							url: '/pages/plantGrass/plant_release/index'
						});
					}else{
						toLogin()
					}
				},
			linkPage(url) {
				if (['/pages/index/index', '/pages/order_addcart/order_addcart',
						'/pages/user/index', '/pages/plant_grass/index'
					].indexOf(url) > -1) {
					uni.switchTab({
						url
					})
				} else {
					uni.navigateTo({
						url
					})
				}
				this.currentPage = false
			},
			// 首页
			goHome() {
				uni.switchTab({
					url: '/pages/index/index'
				});
			},
			goRouter(item) {
				var pages = getCurrentPages();
				var page = (pages[pages.length - 1]).$page.fullPath;
				if (item.link == page) return
				uni.switchTab({
					url: item.link,
					fail(err) {
						uni.redirectTo({
							url: item.link
						})
					}
				})
			},
			getNav() {
				getNavigation().then(res => {
					this.newData = res.data
					if (this.newData.status && this.newData.status.status) {
						uni.hideTabBar()
						this.$set(this, 'swiperHeight', this.windowHeight-50);
					} else {
						uni.showTabBar()
					}
				})
			},
			goRelease(){
				if(this.isLogin){
					uni.navigateTo({
						url: '/pages/plantGrass/plant_release/index'
					});
				}else{
					toLogin()
				}
			},
			followScroll(e){
				this.currentPage=false
				uni.$emit('scroll');
			},
			//分享信息
			shareFriend(item){
				this.shareInfo = item
			},
			// 打开授权
			
			/**
			 * 获取个人用户信息
			 */
			getUserInfo: function() {
				let that = this;
				getUserInfo().then(res => {
					that.userInfo = res.data
				});
			},
			/*获取分类列表*/
			getCateList(){
				getTopicList().then(res => {
					let data = [{cate_name: "推荐",category_id: 0,children: []}]
					if(this.community_app_switch.length == 2 || this.community_app_switch[0]==2){
						data = [{cate_name: "推荐",category_id: 0,children: []},{cate_name: "视频",category_id: -1,children: []}]
					}	
					this.menuList = Array.from(new Set([...data,...res.data]));
				})
			},
			swiperChange(e) {
				let { current, source, currentItemId } = e.detail;
				if (source === 'autoplay' || source === 'touch') {
					this.currentItemId = currentItemId;
					this.swiperCur = current
					this.selectMenu(this.menuList[this.swiperCur],this.swiperCur,false)
					if (this.menuList.length > 6) {
						var tempIndex = this.swiperCur - 2;
						tempIndex = tempIndex <= 0 ? 0 : tempIndex;
						let tabLeft = (this.swiperCur - 2) * this.isWidth; //设置下划线位置
						this.$nextTick(function() {
							this.$set(this, 'tabLeft', tabLeft);
						});
					}
				}
			},
			// 点击列表头部
			selectMenu(item, index, isScroll) {
				this.currentItemId = item.category_id;
				this.swiperCurrent = index;
				this.swiperCur = index
				this.isScroll = isScroll;
				this.tabClick = index; //设置导航点击了哪一个
				this.isLeft = index * this.isWidth; //设置下划线位置
				this.setMenuLeft(index);
			},
			/*导航栏移动位置*/
			setMenuLeft(index) {
				this.getGoods();
			},
			showMore(item){
				this.$set(item,'show', true);
			},
			scrollLeft: function(e){
				this.currentPage=false
				uni.$emit('scroll');
				this.scrollTop = e.detail.scrollTop		
				this.navShow = e.detail.scrollTop >= this.storeHeight - 200;
				if(this.navShow){
					this.$set(this, 'swiperHeight', this.windowHeight-50);
				}
				if(e.detail.scrollTop > e.detail.scrollHeight - 1500){
					if(this.tabActive==1){
						this.getGoods();
					}else{
						this.getFocusArtical()
					}
					
				}
			},
			// 获取发现演唱会音乐会
			getGoods: function() {
				let that = this;
				if(!this.cateGoods[this.currentItemId]) {
					this.$set(this.cateGoods, this.currentItemId, {
						where: {...this.where, category_id: this.currentItemId},
						goods: []
					})
				}
				const data = this.cateGoods[this.currentItemId];
				const cateId = this.currentItemId;
				if (data.goodsLoading || data.goodsLoaded) return;
				data.goodsLoading = true;
				data.loadTitle = "";
				
				if(this.sortIndex==7){
					this.sortIndex = 1
				}else{
					
				}
				uni.setStorageSync('sortIndex',	this.sortIndex )
				graphicLstApi({...data.where,...{ from:'GPT',
				count_start:this.sortIndex ==4?'count_start':'',
				count_reply:this.sortIndex ==2?'count_reply':'' ,
				count_share:this.sortIndex ==3?'count_share':'' ,
				is_hot:this.sortIndex ==1?'is_hot':'' ,
				count_views: this.sortIndex ==5?'count_views':'',
					count_collections: this.sortIndex ==6?'count_collections':''
					
					
				}}).then(res => {
					data.goodsLoading = false;
					data.goodsLoaded = res.data.list.length < that.where.limit;
					if(data.where.page == 1 ){
						data.goods = [];
					}
					data.goods.push.apply(data.goods, res.data.list);
					data.where.page = data.where.page + 1;
					this.$set(this.cateGoods,cateId, {...data});
					this.triggeredDiscover = false;
					this.$forceUpdate()
				}).catch(err => {
					data.goodsLoading = false;
					uni.showToast({
						title: err,
						icon: 'none'
					})
					this.$set(this.cateGoods,cateId, data);
				});
				this.sortIndex++
				
			},
			/*获取关注的人的文章列表*/
			getFocusArtical(){
				let that = this;
				
				if (that.focusLoading || that.focusLoaded) return;
				that.focusLoading = true;
				that.loadTitle = "";
				focusArticleLst(that.focusWhere).then(res => {
					setTimeout(()=>{
						uni.hideLoading()
					},500)
					that.focusLoading = false;
					that.focusLoaded = res.data.list.length < that.focusWhere.limit;
					res.data.list.forEach((item)=>{
						item.show = false
					})
					console.log(that.focusLoading)
					console.log(res)
					this.triggeredDiscover = false;
					that.followList.push.apply(that.followList, res.data.list);
					that.focusWhere.page = that.focusWhere.page + 1;
				}).catch(err => {
					setTimeout(()=>{
						uni.hideLoading()
					},500)
					that.focusLoading = false;
					uni.showToast({
						title: err,
						icon: 'none'
					})
					console.log(that.focusLoading)
				});
				
			},
			onPulling(e) {
				
				if (e.detail.deltaY < 0) return // 防止上滑页面也触发下拉
				if (this.tabActive == 1) {
					this.triggeredDiscover = true;
				} else {
					this.triggeredDiscover = true;
				}
			},
			onPullings(e){
				if (e.detail.deltaY < 0) return // 防止上滑页面也触发下拉
				this.triggeredDiscovers = true;
			},
			onRefreshDiscovers(){
				if (this._freshing) return;
				this._freshing = true;
				// this.params.page = 1;
				setTimeout(() => {
					this._freshing = false;
					this.focusWhere.page=1
					this.triggeredDiscovers = false;
					this.scrollTop = 0;
					this.focusLoading = false;
					this.focusLoaded= false
					this.followList=[]
					this.getFocusArtical();
					uni.stopPullDownRefresh();
					this._freshing = false;
				}, 1000)
			},
			onRefreshDiscover() {
				
				if (this._freshing) return;
				this._freshing = true;
				// this.params.page = 1;
				setTimeout(() => {
					this._freshing = false;
					this.cateGoods = {}
					
					this.getGoods();
					
					
					this.triggeredDiscover = false;
					this.scrollTop = 0;
					
					uni.stopPullDownRefresh();
					this._freshing = false;
				}, 1000)
			},
			onRefresh() {
				if (this._freshing) return;
				this._freshing = true;
				setTimeout(() => {
					this.loadendfollow = false;
					this.loadend = false;
					this.followList = [];
					this.focusWhere.page = 1;
					this.params.page = 1;
					this.getFocusArtical();
					setTimeout(() => {
						if(this.followList.length === 0 || this.focusLoaded) this.getGoods();
					}, 400)
					this.triggered = false
					uni.stopPullDownRefresh();
					this._freshing = false;
				}, 1000)
			},
			onRestores() {
				this.triggeredDiscovers = false;
			},
			onRestore() {
				this.triggeredDiscover = false;
			},
			onAbort() {
				console.log("onAbort");
			},
			// 商铺首页滚动 navbar 吸顶
			scrollHome: function(e) {
				this.navShow = e.detail.scrollTop >= this.storeHeight - 20;
			},
			likeToggle(item){
				let status = item.relevance_id ? 0 : 1
				graphicStartApi(item.community_id,{status: status}).then(res => {
					if(item.relevance_id){
						item.count_start--;
						item.count_start = item.count_start == 0 ? 0 : item.count_start
						item.relevance_id = false
					}else{
						item.count_start++;
						item.relevance_id = true
					}
				});
			},
			/*查看提到的宝贝*/
			openMore(item){
				this.$refs.mentioned.showPopup()
				this.moreList = item.relevance;
				this.authorUid = item.uid
			},
			openCommon(item,index){
				this.switchTab(0);
				this.showComment = true
				this.$refs.comment.getData(item,index);
			},
			commentSucces(index){
				this.followList[index]['count_reply']++
			},
			closePopup(){
				this.$refs.mentioned.closePopup()
			},
			close(){
				this.switchTab(1);
				this.showComment = false;
			},
			onTouchmove(e){
				const query = uni.createSelectorQuery().in(this);
				let that= this
				query.select('#goods').boundingClientRect(data => {
					if(data.bottom < 1500) {
						if(this.tabActive == 1){
							// this.getGoods();
						}else{
							this.getFocusArtical();
						}
					}
				}).exec();
				// query.select('#goodss').boundingClientRect(data => {
						
				// 		if(data&&data.bottom < 1500) {
				// 			if(that.focusLoading) return
				// 				that.focusLoading=false
				// 				that.getFocusArtical();
				// 		}
						
							
						
					
				// }).exec();
				// 模拟触底刷新
			},
			switchTab(type){ //1打开0关闭
				this.newData = this.navigation
				if (this.newData.status && this.newData.status.status) {
					if(type == 1){
						this.showTab = true;
						uni.hideTabBar()
					}else{
						this.showTab = false;
						uni.hideTabBar()
					}
				} else {
					if(type == 1){
						this.showTab = false;
						uni.showTabBar()
					}else{
						this.showTab = false;
						uni.hideTabBar()
					}
				}			
			},
			goVideo(item) {
				uni.navigateTo({
					//#ifdef APP
					url: '/pages/short_video/appSwiper/index?id='+item.community_id+'&from=GPT'
					//#endif
					//#ifndef APP
					url: '/pages/short_video/nvueSwiper/index?id='+item.community_id+'&from=GPT'
					//#endif
				});
			},
		},
		onReachBottom() {
			console.log(333)
			if(this.tabActive == 1){
				this.getGoods();
			}else{
				this.getFocusArtical();
			}
		},
		beforeDestroy() {
			uni.$off('startLike');
		}
	}
</script>

<style lang="scss" scoped>
page{
	background: #fff;
}
.page_con{
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	display: flex;
	flex-direction: column;
	background-color: #fff;
}
.longTab {
	display: flex;
	width: 100%;
	background: #fff;
	border-radius: 16rpx 16rpx 0 0;
	padding: 12rpx 20rpx ;
	.longItem {
		height: 50upx;
		display: inline-block;
		line-height: 50upx;
		text-align: center;
		font-size: 25rpx;
		color: #847F7F;
		max-width: 160rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		overflow-x: scroll;
		overflow-y: hidden;
		margin-right: 56rpx;
		&:last-child{
			margin-right: 0;
		}
		/*解决ios上滑动不流畅*/
		-webkit-overflow-scrolling: touch;
		position: relative;
		&.click {
			font-weight: 800;
			font-size: 28rpx;
			color: #000000;
			
		}
	}
	.underlineBox {
		height: 3px;
		width: 20%;
		display: flex;
		align-content: center;
		justify-content: center;
		.underline {
			opacity: 0;
			width: 60rpx;
			height: 4rpx;
			background-color: #e93323;
		}
	}
}
.tab-cont{
	border-radius: 16rpx 16rpx 0 0;
}
.showFoot{
	padding: 20rpx 20rpx calc(120rpx+ constant(safe-area-inset-bottom));
	padding: 20rpx 20rpx calc(120rpx + env(safe-area-inset-bottom));
}
.follow_count{
	background: #ffffff;
	/* #ifndef MP */
	padding: 20rpx 20rpx 100rpx;
	/* #endif */
	/* #ifdef MP */
	padding: 20rpx 20rpx calc(0rpx+ constant(safe-area-inset-bottom));
	padding: 20rpx 20rpx calc(0rpx + env(safe-area-inset-bottom));
	/* #endif */
	.title{
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.author{
		display: flex;
		align-items: center;
		.picture{
			width: 78rpx;
			height: 78rpx;
			border-radius: 100%;
			overflow: hidden;
		}
		/deep/image,/deep/.easy-loadimage,uni-image{
			height: 78rpx;
		}
		.name{
			margin-left: 20rpx;
			color: #333333;
			font-size: 32rpx;
			font-weight: bold;
		}
	}
	.time{
		color: #999999;
		font-size: 24rpx;
	}
	.product{
		margin-top: 20rpx;
		border-radius: 16rpx;
	}
	.icon-fenxiang2{
		color: #282828;
		font-size: 46rpx;
		background: transparent;
	}
}
.list_count{
	margin-bottom: 70rpx;
	&:last-child{
		margin-bottom: 0;
	}
}
.videoSwiper{
	width: 710rpx;
	height: 710rpx;
	position: relative;
	border-radius: 16rpx;
	.image{
		width: 710rpx;
		height: 710rpx;
		border-radius: 16rpx;
	}
	.video_img{
		width: 100rpx;
		height: 100rpx;
		position: absolute;
		top: 50%;
		left: 50%;
		margin-left: -50rpx;
		margin-top: -50rpx;
		z-index: 10;
	}
}
.pro_describle{
	.mentioned{
		padding: 20rpx 0;
		display: flex;
		align-items: center;
		justify-content: space-between;
		border-bottom: 1px solid #F5F5F5;
		.title{
			color: #666666;
			font-size: 26rpx;
		}
	}
	.product_more{
		max-width: 360rpx;
		display: flex;
		align-items: center;
		.more_image{
			width: 58rpx;
			height: 58rpx;
			border-radius: 5rpx;
			margin-right: 12rpx;
			display: inline-block;
			border: 1px solid #BBBBBB;
		}
		/deep/image,/deep/.easy-loadimage,uni-image{
			width: 58rpx;
			height: 58rpx;
		}
		.iconfont{
			color: #CCCCCC;
			margin-left: 10rpx;
		}
	}
	.product_info{
		line-height: 45rpx;
		margin: 20rpx 0;
		.text{
			font-size: 28rpx;
			color: #282828;
		}
		.unfold_btn{
			margin-left: 30rpx;
			font-size: 30rpx;
			color: #282828;
			font-weight: bold;
		}
	}
	.product_cate{
		margin: 20rpx 0;
		display: inline-block;
		>view{
			display: flex;
			align-items: center;
			background: var(--view-minorColor);
			border-radius: 30rpx;
			padding: 0 25rpx;
			line-height: 56rpx;
			height: 56rpx;
			color: var(--view-theme);
			.text{
				font-size: 28rpx;
			}
			.icon{
				font-size: 35rpx;
				font-weight: bold;
				margin-right: 10rpx;
			}
		}
	}
	.foot_bar{
		display: flex;
		align-items: center;
		justify-content: space-between;
		.item{
			display: flex;
			align-items: center;
			color: #282828;
			&.icon-fenxiang2{
				font-size: 46rpx;
			}
		}
		.item_count{
			font-size: 26rpx;
			display: flex;
			align-items: center;
			&:first-child{
				margin-right: 30rpx;
			}
			.iconfont{
				font-size: 40rpx;
				margin-right: 5rpx;
			}
			.icon-shoucang1{
				color: var(--view-priceColor);
			}
		}
	}
}

.grass_header {
	display: flex;
	flex-direction: column;
	background-size: cover;
	background-color: #ffffff;
	width: 100%;
	z-index: 10;
}
.header {
	padding: 0 30rpx 20rpx;
	.navTab{
		position: relative;
		box-sizing: border-box;
		height: 58rpx;
		padding-top:2rpx;
		// padding: 20rpx 0;
			
		.acea-row{
			width: 400rpx;
			padding-left: 140rpx;
			margin:0 auto;
			position: relative;
			
		}
		.nav-item{
			font-size: 28rpx;
			color: #5B5B5B;
			// margin-right: 92rpx;
			&.on{
				font-size: 28rpx;
				color: #010101;
				font-weight: bold;
			}
		}
		.release_btn{
			width: 58rpx;
			height: 58rpx;
			border-radius: 100%;
			background-image: linear-gradient(126deg, var(--view-bntColor21) 0%, var(--view-bntColor22) 100%);
			color: #fff;
			position: absolute;
			top: 20rpx;
			left: 0;
			.iconfont{
				font-size: 28rpx;
			}
		}
		.avatar{
			width: 58rpx;
			height: 58rpx;
			border-radius: 100%;
			border: 3rpx solid rgba(0,0,0,.05);
			position: absolute;
			top: 20rpx;
			right: 0;
		}
	}
	.search_count{
		display: flex;
		align-items: center;
		justify-content: space-between;
		.search_topic{
			width: 46rpx;
			height: 46rpx;
			image,.topic_icon,uni-image{
				width: 46rpx;
				height: 46rpx;
			}
		}
	}
	.search {
		display: flex;
		align-items: center;
		min-width: 0;
		height: 58rpx;
		border-radius: 29rpx;
		background-color: #FFFFFF;
		font-weight: 500;
		font-size: 24rpx;
		color: #999999;
		width: 609rpx;
		.iconfont {
			margin-right: 13rpx;
			margin-left: 30rpx;
			font-size: 24rpx;
		}
	}
}
.main_count{
	background-color: #ffffff;
	padding: 30rpx 20rpx;
	.list{
		width: 710rpx;
		height: 280rpx;
		margin-bottom: 30rpx;
		position: relative;
		.picture{
			width: 710rpx;
			height: 280rpx;
			border-radius: 16rpx;
		}
	}
}
.main {
	flex: 1;
	height: auto;
	&.scroll-main{
		min-height: 60vh;
	}
}
.nav.fixed {
	position: fixed;
	left: 0;
	width: 100%;
	.nav-cont {
		position: absolute;
		width: 100%;
	}
}
.goods {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	padding: 0 20rpx 100rpx;
	background: #ffffff;
	box-sizing: border-box;
	width: 750rpx;
	/* #ifdef H5 */
	// padding-bottom: 90rpx;

	/* #endif */
	.item {
		width: 360rpx;
		border-radius: 16rpx;
		margin-bottom: 20rpx;
		background-color: #FFFFFF;
		overflow: hidden;
		/deep/.image,/deep/.easy-loadimage,uni-image {
			width: 360rpx;
			height: 345rpx;
			image {
				display: block;
				width: 100%;
				height: 100%;
			}
		}
		.text {
			padding: 20rpx 20rpx 25rpx;
			.name {
				font-weight: 500;
				font-size: 30rpx;
				line-height: 1;
				color: #222222;
				display: flex;
				align-items: center;
				.name_text{
					display: inline-block;
					max-width: 400rpx;
				}
			}
			.money-wrap {
				display: flex;
				align-items: center;
				margin-top: 43rpx;
				.money {
					font-weight: bold;
					font-size: 26rpx;
					color: $theme-color;
					text {
						font-size: 34rpx;
						line-height: 1;
					}
				}
				.ticket {
					height: 26rpx;
					padding-right: 9rpx;
					padding-left: 9rpx;
					border: 1px solid $theme-color;
					border-radius: 4rpx;
					margin-left: 10rpx;
					font-weight: 500;
					font-size: 20rpx;
					line-height: 24rpx;
					color: $theme-color;
				}
			}
			.score {
				margin-top: 20rpx;
				font-weight: 500;
				font-size: 20rpx;
				line-height: 1;
				color: #737373;
			}
		}
		.foot {
			display: flex;
			justify-content: center;
			align-items: center;
			height: 52rpx;
			background: linear-gradient(to right, #F11B09, #F67A38);
			font-weight: 500;
			font-size: 24rpx;
			color: #FFFFFF;
			.iconfont {
				margin-right: 10rpx;
				font-size: 22rpx;
				line-height: 1;
			}
		}
	}
}

.page-footer {
	position: fixed;
	bottom: 0;
	z-index: 30;
	display: flex;
	align-items: center;
	justify-content: space-around;
	width: 100%;
	height: 98rpx;
	height: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
	height: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
	box-sizing: border-box;
	border-top: solid 1px #F3F3F3;
	background-color: #fff;
	box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
	padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
	padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
	.foot-item {
		display: flex;
		width: max-content;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		position: relative;
		.count-num {
			position: absolute;
			display: flex;
			justify-content: center;
			align-items: center;
			width: 40rpx;
			height: 40rpx;
			top: 0rpx;
			right: -15rpx;
			color: #fff;
			font-size: 20rpx;
			background-color: #FD502F;
			border-radius: 50%;
			padding: 4rpx;
		}
	}
	.foot-item image {
		height: 50rpx;
		width: 50rpx;
		text-align: center;
		margin: 0 auto;
	}
	.foot-item .txt {
		font-size: 24rpx;
	}
}
.line{
	background: #E6E6E6;
	width: 100vw;
	height: 2rpx;
	margin-top: 10rpx;
}
.btn {
		position: fixed;
		right: 40rpx;
		top: 20rpx;
		// margin-left: 30rpx;
		.iconfont {
			font-size: 45rpx;
			color: #000;
		}
		.iconnum {
			min-width: 6px;
			background-color: #fff;
			color: var(--view-theme);
			border-radius: 15rpx;
			position: absolute;
			right: -10rpx;
			top: -10rpx;
			font-size: 10px;
			padding: 0 4px;
		}
	}
</style>
<style lang="scss">
	.head-wrapper {
		z-index: 999;
		display: flex;
		align-items: center;
		position: fixed;
		left:12rpx;
		top: 0;
	}
	.head-menu {
		display: flex;
		align-items: center;
		height: 58rpx;
		width: 158rpx;
		background: rgba(255,255,255,0.302);
		border: 2rpx solid rgba(0,0,0,0.0588);
		border-radius: 29rpx;
		.iconfont {
			flex: 1;
			text-align: center;
			color: #000000;
			box-sizing: border-box;
			&.icon-fanhui2 {
				height: 40rpx;
				line-height: 40rpx;
				position: relative;
					
				&::after{
					position: absolute;
					clear: both;
					content: '';
					right: 0;
					height: 30rpx;
					width: 2rpx;
					top: 0;
					bottom: 0;
					margin: auto;
					background:  rgba(0, 0, 0, 0.2);
				}
			}
		}
	}
	
</style>